<?php
/* @var $this LoginListController */
/* @var $model LoginList */
/* @var $form CActiveForm */
$user_service_id = Yii::app()->request->getParam(user_service_id);
if($user_service_id!=""){
	$user_service_id = $user_service_id;
}else{
	$user_service_id = $model->user_service_id;
}
$rs = UserService::model()->find('user_service_id='.$user_service_id);
$rs2=Service::model()->find('service_id='.$rs->service_id);
$service_id=$rs->service_id;
$service=$rs2->code;
?>
<?php 
	if(yii::app()->user->level==1){
	$model2=Loginlist::model();
	$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'login-list-grid',
	'dataProvider'=>$model2->search2(),
	'itemsCssClass'=>'responsive table table-striped table-bordered',

	'pagerCssClass'=>'pagination pull-right',

	'cssFile'=>false,
	'columns'=>array(
		array('name'=>'login_list_id','headerHtmlOptions'=>array('style'=>"width:15%;"),'value'=>'LoginList::model()->getUserName($data->login_list_id)'),
		array('name'=>'user_service_id','headerHtmlOptions'=>array('style'=>"width:15%;"),'value'=>'UserService::model()->getServiceName($data->user_service_id)'),
		array('name'=>'field1','headerHtmlOptions'=>array('style'=>"width:15%;"),'value'=>'LoginList::model()->getVpnServerName($data->login_list_id,$data->field1)'),
		array('name'=>'field2','headerHtmlOptions'=>array('style'=>"width:15%;")),
		array('name'=>'field3','headerHtmlOptions'=>array('style'=>"width:10%;")),
		array('name'=>'field4','headerHtmlOptions'=>array('style'=>"width:10%;")),
		/*
		'field5',
		'field6',
		'field7',
		'field8',
		*/
		
		array(
			'class'=>'CButtonColumn',
			'header'=>Yii::t('base','Operate'),
			'template'=>'{delete}{update}',
			'updateButtonImageUrl'=>array('class'=>'gicon-edit'),
			'updateButtonOptions'=>array('class'=>'btn btn-small'),
			'deleteButtonImageUrl'=>array('class'=>'gicon-edit'),
			'deleteButtonOptions'=>array('class'=>'btn btn-inverse btn-small'),
			'template'=>'{update}{delete}',
			'headerHtmlOptions'=>array('style'=>'width:20%'),
		),
		
	),
)); }?>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'login-list-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?></p>

	<?php echo $form->errorSummary($model); ?>
	<?php if($user_service_id!=""){?>
	<input size="60" maxlength="255" name="LoginList[user_service_id]" id="LoginList_user_service_id" type="hidden" value="<?php echo $user_service_id;?>">
	<?php }else{?>
	<input size="60" maxlength="255" name="LoginList[user_service_id]" id="LoginList_user_service_id" type="hidden" value="<?php echo $model->user_service_id;?>">
	<?php } ?>
	<div class="row">
	<?php 
		if($service.'_field1'!=Yii::t('base',$service.'_field1')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field1')); ?>
		
		<?php 
			if($service_id==3 || $service_id==14)	//3 是电话 14是IPTV
				echo $form->textField($model,'field1',array('size'=>60,'maxlength'=>255)); 
			else if($service_id==8)
				echo $form->dropDownList($model,'field1',Vpnlist::model()->getvpnlist($user_service_id)); 
		?>
		<?php echo $form->error($model,'field1'); ?>
		<?php } ?>
	</div>

	<div class="row">
	<?php 
		if($service.'_field2'!=Yii::t('base',$service.'_field2')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field2')); ?>
		<?php echo $form->textField($model,'field2',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'field2'); ?>
		<?php } ?>
	</div>

	<div class="row">
	<?php 
	if($service.'_field3'!=Yii::t('base',$service.'_field3')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field3')); ?>
		<?php echo $form->textField($model,'field3',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'field3'); ?>
		<?php }?>
	</div>
		<div class="row">
	<?php if($service.'_field4'!=Yii::t('base',$service.'_field4')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field4')); ?>
		<?php 
		if($service_id==3)
				 echo $form->dropDownList($model,'field4',
				 	array(
							'1'=>Yii::t('base','button_option_callback'),
							'2'=>Yii::t('base','button_option_1888'),
							'3'=>Yii::t('base','button_option_114'),
							'4'=>Yii::t('base','button_option_recharge'),
							'5'=>Yii::t('base','button_option_phonecard'),
						));
			else 
			 	 echo $form->textField($model,'field4',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'field4'); ?>
	<?php } ?>
	</div>

	<div class="row">
	<?php if($service.'_field5'!=Yii::t('base',$service.'_field5')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field5')); ?>
		<?php 
		if($service_id==3)
				 echo $form->dropDownList($model,'field5',
				 	array(
							'1'=>Yii::t('base','button_option_callback'),
							'2'=>Yii::t('base','button_option_1888'),
							'3'=>Yii::t('base','button_option_114'),
							'4'=>Yii::t('base','button_option_recharge'),
							'5'=>Yii::t('base','button_option_phonecard'),
						));
			else 
			 	 echo $form->textField($model,'field5',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'field5'); ?>
		<?php } ?>
	</div>

	<div class="row">
	<?php if($service.'_field6'!=Yii::t('base',$service.'_field6')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field6')); ?>
		<?php echo $form->textField($model,'field6',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'field6'); ?>
		<?php } ?>
	</div>

	<div class="row">
	<?php if($service.'_field7'!=Yii::t('base',$service.'_field7')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field7')); ?>
		<?php echo $form->textField($model,'field7',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'field7'); ?>
		<?php } ?>
	</div>

	<div class="row">
	<?php if($service.'_field8'!=Yii::t('base',$service.'_field8')){?>
		<?php echo $form->labelEx($model,Yii::t('base',$service.'_field8')); ?>
		<?php echo $form->textField($model,'field8',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'field8'); ?>
		<?php } ?>
	</div>
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Create') : Yii::t('base','Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->